package com.tnovoselec.android.ui.imagegallery;

import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;

public abstract class ImageGalleryAdapter extends PagerAdapter {

    /**
     * @param position
     * @return return {@link View}, possibly {@link TouchImageView} or
     *         {@link ViewGroup} that contains TouchImageView in its hierarchy
     */
    public abstract View getView(int position);

    @Override
    public Object instantiateItem(View container, int position) {
	final View view = getView(position);
	((ViewPager) container).addView(view, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
	// ((ViewPager) container).addView(view);
	return view;
    }

    @Override
    public void destroyItem(View container, int position, Object object) {
	((ViewPager) container).removeView((View) object);
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
	return object == view;
    }

    @Override
    public void restoreState(Parcelable arg0, ClassLoader arg1) {
    }

    @Override
    public Parcelable saveState() {
	return null;
    }

    @Override
    public void startUpdate(View container) {
    }

    @Override
    public void finishUpdate(View container) {
    }

}
